package alejandro.castro.arkanoid;

import java.awt.Dimension;

import alejandro.castro.bolita.Bolita;
import alejandro.castro.ladrillo.Ladrillo;
import alejandro.castro.paleta.Paleta;

import com.uqbar.vainilla.Game;

public class ArkanoidGame extends Game {

	public static void main(String[] args) {
		ArkanoidDesktopGameLauncher game = new ArkanoidDesktopGameLauncher(
				new ArkanoidGame());
		game.launch(); 

	}

	@Override
	protected void initializeResources() {
		// Nothing here

	}

	@Override
	protected void setUpScenes() {
		ArkanoidScene scene = new ArkanoidScene();
		scene.agregarBolita(new Bolita());
		scene.agregarPaleta(new Paleta());
		agregarLadrillos(scene);
		this.setCurrentScene(scene);
	}

	private void agregarLadrillos(ArkanoidScene scene) {
		int ROWS = 3;
		int HEIGHTL = 20;
		int COLUMNS = 6;
		int MARGINX = 8; // separacion entre ladrillos
		int MARGINY = 8; // separacion entre ladrillos
		int Y_FIRSTCOLUMN = 20;
		
		
		int widthL = ((this.getDisplayWidth() - MARGINX )/ COLUMNS) - MARGINX;
		int widthPlusMargin = widthL + MARGINX;
		int lastX = this.getDisplayWidth() - widthL;
		int heightPlusMargin = HEIGHTL + MARGINY;
		int lastY = ((ROWS - 1) * MARGINY) + ROWS*HEIGHTL + Y_FIRSTCOLUMN;
		
		
		

		for (int xPos = MARGINX; xPos < lastX; xPos += widthPlusMargin) {
			for (int yPos  = Y_FIRSTCOLUMN; yPos < lastY; yPos += heightPlusMargin) {
				scene.agregarLadrillo(new Ladrillo(xPos, yPos, widthL, HEIGHTL));
			}
		}
	}

	@Override
	public Dimension getDisplaySize() {
		return new Dimension(500, 600);
	}

	@Override
	public String getTitle() {
		return "ARKANOID-ORIYINAL";
	}

}
